package 笔试.便利蜂;

import java.util.Arrays;
import java.util.Scanner;

public class Demo3 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();
        String[] arr = str.split(",");
        int[] nums = new int[arr.length];//重量数组
        for (int i = 0; i < arr.length; i++) {
            nums[i] = Integer.parseInt(arr[i]);
        }
        int boxCapacity = sc.nextInt(); //箱子承重量
        Arrays.sort(nums);
        int count = 0;
        int tmp = 0;
        for (int i = 0; i < nums.length; i++) {
            if(tmp+nums[i]>boxCapacity){
                break;
            }
            count++;
            tmp += nums[i];

        }
        System.out.println(count);


    }
}
